package java0914;

public class Demo {
    public static void main(String[] args) {
        int array[] = new int[]{1,2,3,4,5,6,7,8,9,10};
        //insertSort(array);
//        bubbleSort(array);
//        for (int x:array) {
//            System.out.print(x+" ");
//        }
        float ans = score(array);
        System.out.println("平均分为:"+ans);

    }
    public static float score(int array[]){
        int max = array[0];
        int min = array[0];
        int ret = 0;
        for (int i = 0; i < array.length; i++) {
            if (array[i] > max){
                max = array[i];
            }
            if (array[i] < min){
                min = array[i];
            }
            ret += array[i];
        }
        ret = ret - (max+min);
        float ans = 1.0f*ret / 8;
        return ans;
    }
}
class demo2 {
    public static void main(String[] args) {
        int a[] = new int[]{10,8,9,9,9};
        int b[] = new int[]{10,10,7,9,9};
        float aAver = average(a);
        float bAver = average(b);
        if (aAver == bAver){
            double aVar = Variance(a,aAver);
            double bVar = Variance(b,bAver);
            if (aVar > bVar){
                System.out.println("甲选手成绩更好!");
            }else {
                System.out.println("乙选手成绩更好!");
            }
        }else{
            if (aAver > bAver){
                System.out.println("甲选手成绩更好!");
            }else {
                System.out.println("乙选手成绩更好!");
            }
        }
    }
    public static float average(int array[]){
        int ret =0;
        for (int x: array) {
            ret += x;
        }
        return ret/array.length*1.0f;
    }
    //求方差
    public static double Variance(int[] x,float ave){
        double dVar = 0.0;
        for(int i=0;i<x.length;i++){//求方差
            dVar+=(x[i]-ave)*(x[i]-ave);
        }
        return dVar/x.length;
    }
}